Repository navigation
feat(prepare-sources): implement plugin-removal module (RHIDP-15835) - #174
davidfestal wants to merge 2 commits into
Conversation
d5dd7f4 to
bcbab9a
Compare
Generate manifest.json (workspace package inventory) and, when the workspace contains backstage:^ dependencies, backstage-manifest.json with @backstage package metadata extracted from yarn.lock and validated against versions.backstage.io. Add a zero-dependency Yarn Berry lockfile parser/serializer for round-trip fidelity, shared manifest types, and fixture-based tests. Extend test utilities with a mockFetch helper and wire the module into the pipeline runner. Add @vitest/coverage-v8 and ignore the coverage directory. Assisted-by: Cursor Signed-off-by: David Festal <dfestal@redhat.com>
Intersect `plugins-list.yaml` with `rhdh-supported-packages.txt` for the current workspace, preserve packages referenced by `dist-dynamic/embedded/*/package.json`, remove infrastructure directories (`packages/app`, `packages/backend`, `.storybook`, `examples/`, `node_modules`), and delete remaining non-supported plugin directories. Rewrite the filtered `plugins-list.yaml` back to the overlay path, preserving full lines including export CLI args. Expose `overlayRepoRoot` on `PipelineInputs` so tier-list files can be read from the overlay repository root instead of resolving `../..` inside the module. Update the fixture loader to support an `input/overlay-root/` directory for tier-list fixtures. Add the module implementation, unit tests, fixtures, and README.md; wire the module into the pipeline runner. Assisted-by: Cursor Signed-off-by: David Festal <dfestal@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: David Festal <dfestal@redhat.com>
|
| export function collectEmbeddedPackageNames(workspacePath: string): Set<string> { | ||
| const names = new Set<string>(); | ||
| const pattern = path.join(workspacePath, "**/dist-dynamic/embedded/*/package.json"); | ||
| for (const pkgPath of fs.globSync(pattern)) { | ||
| try { | ||
| const name = readPackageName(pkgPath); | ||
| if (name) names.add(name); | ||
| } catch { | ||
| // skip malformed package.json — same tolerance as sync-midstream jq | ||
| } | ||
| } | ||
| return names; | ||
| } |
There was a problem hiding this comment.
This scans every **/dist-dynamic/embedded/*/package.json under the workspace, including embeds that live under plugins we're about to delete. In sync-midstream the plugins-list filter runs first, so embeds only come from packages that survive.
Here the initial export already ran on the full list, so an embed from a non-supported plugin can still pin a sibling source via shouldKeepPackageDir and keep a directory we'd otherwise remove.
Could we limit the scan to embeds under keepPluginPaths (the surviving list), or if the over-keep is intentional, call that out and add a fixture that documents it?
| for (const pattern of infraPatterns) { | ||
| for (const dir of fs.globSync(pattern)) { | ||
| if (!fs.statSync(dir).isDirectory()) continue; | ||
| fs.rmSync(dir, { recursive: true, force: true }); |
There was a problem hiding this comment.
Before this line on glob results, can we resolve the path and skip anything that isn't still under workspacePath? Same idea as keeping ../.. out of the module a symlink or odd glob hit shouldn't be able to delete outside the workspace. Same check would help at the package-dir delete around line 209.



plugin-removalpipeline moduleImplements the
plugin-removalstep of the source-preparation pipeline (RHIDP-15835).What it does:
plugins-list.yamlwithrhdh-supported-packages.txtto keep only supported pluginsdist-dynamic/embedded/*/package.json)packages/app,packages/backend,examples/,.storybook,node_modules)plugins-list.yamlpreserving comments, blank lines, and CLI argsPipeline changes:
overlayRepoRoottoPipelineInputs(needed to read tier-list files from the overlay repo root)input/overlay-root/support for tier-list test scenariosTests: 5 fixture tests + 8 unit tests, 100% coverage (statements, branches, functions, lines).
NOTE: Based on top of PR #166 which should be merged first